#!/usr/bin/env bash
set -e

SRC_FILR=${1}
PACKAGE=${2}
TYPE=${3}
DES=${4}
# uppcase the first char
PREFIX="$(tr '[:lover:]' '[:upper:]') <<< ${TYPE:0:1}${TYPE:1}"

DES_FILE=$(echo ${TYPE}| tr '[:upper:]' '[:lower:]')_${DES}.go
sed 's/PACKAGE_NAME/'"${PACKAGE}"'/g' ${SRC_FILE} | \
    sed 's/GENERIC_TYPE/'"${TYPE}"'/g' | \
    sed 's/GENERIC_NAME/'"${PREFIX}"'/g' > ${DES_FILE}